﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ITM495.OOExamples.Core.Logger
{
    public class FileLogger: ILogger
    {
        public String FilePath { get; set; }

        public StreamWriter Stream { get; set; }

        public FileLogger(string path)
        {
            Stream = new StreamWriter(path);

            FilePath = path;
        }

        #region ILogger Members

        public void Log(string message)
        {
            Stream.WriteLine(message);
            Stream.Flush();
        }

        public void Log(string format, params object[] options)
        {
            Stream.WriteLine(format, options);
            Stream.Flush();
        }

        public void Dispose()
        {
            if (Stream != null)
            {
                Stream.Write("File Logger closing...");
                Stream.Close();
            }
        }

        #endregion
    }
}